<?php
/**
 * 
 * Singleton base class
 * 
 * @category Framework
 * @package ROOT
 * @subpackage Singleton
 * @author Jiania J Hung <jiania@gmail.com>
 * @copyright http://www.jiania.com
 * @since php5.1.x
 *  
 */


class Singleton

{
	/**
	 * hold $instance object of a class
	 *
	 * @var sring $instance
	 */
	private static $_instance=array();
	
	/**
	 * private constructor,so you cann't use $instance=new Singleton()
	 *
	 */
	//private function __construct(){}
	
	/**
	 * final private __clone memthod,so you can' user __clone method in you all subclass
	 *
	 */
	
    final private function __clone(){}
	
	/**
	 * the getInstance memthod returns  a single instance of the object
	 * @return $instance
	 */
	
	
	public static function getInstance($class)
	
	{
		if(!isset(self::$_instance[$class]))
		{

			return self::$_instance[$class]=new $class;
		}
		return self::$_instance[$class];
	}
}

